home *** CD-ROM | disk | FTP | other *** search
/ Freelog 46 / Freelog046.iso / Alu / Celestia / Win32LoresTex / celestia-lores-win32-1.3.0.exe / {app} / shaders / night_arb.vp < prev    next >
Text File  |  2003-02-17  |  1KB  |  43 lines

  1. !!ARBvp1.0
  2.  
  3. # Night texture lighting
  4.  
  5. ATTRIB iPos          = vertex.position;
  6. ATTRIB iNormal       = vertex.normal;
  7. ATTRIB iTex0         = vertex.texcoord[0];
  8. PARAM  mvp[4]        = { state.matrix.mvp };
  9. PARAM  lightDir      = program.env[0];
  10. PARAM  diffuse       = program.env[2];
  11. PARAM  zeroVec       = { 0, 0, 0, 0 };
  12. PARAM  one           = 1;
  13. OUTPUT oPos          = result.position;
  14. OUTPUT oColor        = result.color;
  15. OUTPUT oTex0         = result.texcoord[0];
  16.  
  17. TEMP   diffuseFactor;
  18.  
  19. # Transform the vertex by the modelview matrix
  20. DP4   oPos.x, mvp[0], iPos;
  21. DP4   oPos.y, mvp[1], iPos;
  22. DP4   oPos.z, mvp[2], iPos;
  23. DP4   oPos.w, mvp[3], iPos;
  24.  
  25. # Compute the diffuse light component
  26. DP3   diffuseFactor, iNormal, lightDir;
  27. # Clamp the diffuse component to zero
  28. MAX   diffuseFactor, diffuseFactor, zeroVec;
  29.  
  30. # Use the fourth power of L dot N to create a sharper division between
  31. # the lit and unlit sides of the planet.
  32. ADD   diffuseFactor, one, -diffuseFactor;
  33. MUL   diffuseFactor, diffuseFactor, diffuseFactor;
  34. MAD   diffuseFactor, diffuseFactor, -diffuseFactor, one;
  35.  
  36. # Output the texture
  37. MOV   oTex0, iTex0;
  38. # Output the primary color
  39. MUL   oColor, diffuse, diffuseFactor;
  40.  
  41. END
  42.  
  43.